<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>专线添加</title>
  <link href="__PUBLIC__/css/admin/reset.css" rel="stylesheet" type="text/css">
  <link href="__PUBLIC__/css/admin/zh-cn-system.css" rel="stylesheet" type="text/css">
  <link href="__PUBLIC__/css/admin/table_form.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles1.css" title="styles1" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles2.css" title="styles2" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles3.css" title="styles3" media="screen">
  <link rel="alternate stylesheet" type="text/css" href="__PUBLIC__/css/admin/style/zh-cn-styles4.css" title="styles4" media="screen">
  <script type="text/javascript" src="__PUBLIC__/js/admin/jquery.min.js"></script>
  <script type="text/javascript" src="__PUBLIC__/js/admin/jquery.cookie.js"></script>
  <script type="text/javascript" src="__PUBLIC__/js/admin/styleswitch.js"></script>
  <script type="text/javascript" src="__PUBLIC__/js/admin/admin_common.js"></script>
  <script language="javascript" type="text/javascript" src="__PUBLIC__/js/admin/formvalidator.js" charset="UTF-8"></script>
  <script language="javascript" type="text/javascript" src="__PUBLIC__/js/admin/formvalidatorregex.js" charset="UTF-8"></script>
    <style type="text/css">
         select,input{
            width:300px;
            height: 30px;
        }
         input[type="radio"]{
             width: auto;
             height: auto;
         }
        #wjz input{
            width: 50px;
        }
    </style>
</head>
<body>
  <div class="subnav">
    <div class="content-menu ib-a blue line-x">
      <a class="add fb" href="__MODULE__/Zhuanxian/add"><em>添加专线</em></a>&nbsp;&nbsp;&nbsp;<a class="" href="__MODULE__/Zhuanxian/index"><em>专线管理</em></a>
    </div>
  </div>
  <style type="text/css">
  html{_overflow-y:scroll}
  </style>
  <div class="pad-lr-10">
      <form  action="__MODULE__/Zhuanxian/add" method="post" onsubmit="return chked()">

          <table cellpadding=0 cellspacing=0 class="table_form" width="100%">
              <tr>
                  <td width="15%" align="right">渠道：</td>
                  <td width="90%">
                      <select name="channel_id" id="channel" required="" oninvalid="setCustomValidity('请选择渠道');" oninput="setCustomValidity('')">
                          <option value="">请选择</option>
                          <foreach name="channel" item="val">
                              <option value="<!--{$val['id']}-->"><!--{$val['company']}--></option>
                          </foreach>
                      </select>
                  </td>
              </tr>
              <tr class="part">
                  <td width="15%" align="right">分区：</td>
                  <td width="90%">
                      <select name="partition_id" id="partition" required="" oninvalid="setCustomValidity('请选择渠道');" oninput="setCustomValidity('')">
                          <option value="">请选择</option>
                          <foreach name="partition" item="val">
                              <if condition="$val['id']==1">
                                  <option value="<!--{$val['id']}-->" selected><!--{$val['partition']}--></option>
                              <else/>
                                  <option value="<!--{$val['id']}-->"><!--{$val['partition']}--></option>
                              </if>
                          </foreach>
                      </select>
                  </td>
              </tr>
              <tr>
                  <td width="10%" align="right">国家：</td>
                  <td width="90%">
                      <select name="country_id" id="country" required="" oninvalid="setCustomValidity('请选择国家');" oninput="setCustomValidity('')">
                          <foreach name="country" item="val">
                              <option value="<!--{$val[id]}-->"><!--{$val['ename']}-->&nbsp;&nbsp;<!--{$val['cname']}--></option>
                          </foreach>
                      </select>
                  </td>
              </tr>
              <tr>
                  <td width="10%" align="right">计算方式：</td>
                  <td width="90%">
                      <input type="text" name="method" id="method" class="input-text"/>
                      <!--<input type="number" step="0.01" min="0" class="input-text" name="start_weight" id="start_weight" value=""  required oninvalid="setCustomValidity('请输入底重');" oninput="setCustomValidity('')"/>--><span></span>
                  </td>
              </tr>
              <tr>
                  <td width="10%" align="right">注意事项：</td>
                  <td width="90%">
                      <textarea name="announcements" id="announcements" style="width:300px;height:70px;resize:none;" cols="50" rows="10"></textarea>
                      <!--<input type="number" step="0.01" min="0" class="input-text" name="start_weight" id="start_weight" value=""  required oninvalid="setCustomValidity('请输入底重');" oninput="setCustomValidity('')"/>--><span></span>
                  </td>
              </tr>
              <tr>
                  <td width="10%" align="right">时效：</td>
                  <td width="90%">
                      <input type="text" name="prescription" id="Prescription" class="input-text"/>
                  </td>
              </tr>
              <tr>
                  <td width="10%" align="right">燃油：</td>
                  <td width="90%">
                      <input type="number" step="0.01" min="0"  class="input-text" name="fuel" id="fuel" value=""   oninvalid="setCustomValidity('请输入续重价');" oninput="setCustomValidity('')"/>% <span></span>
                  </td>
              </tr>
              <tr>
                  <td></td>
                  <td>
                      <input type="radio" name="type" id="you" value="1" checked/>有续重&nbsp;&nbsp;
                      <input type="radio"name="type" id="wu" value="0"/>无续重
                  </td>
              </tr>
          </table>
              <div id="yjz" style="display: block;width: 100%" class="table_form">
                  <table cellpadding=0 cellspacing=0 class="table_form" width="100%">
                      <tr>
                          <td width="15%" align="right">每段底重：</td>
                          <td width="90%">
                              <input type="number" step="0.01" min="0" class="input-text" name="start_weight" id="start_weight" value=""  required oninvalid="setCustomValidity('请输入底重');" oninput="setCustomValidity('')"/>kg<span></span>
                          </td>
                      </tr>
                      <tr>
                          <td width="10%" align="right">每段单/底价：</td>
                          <td width="90%">
                              <input type="number" step="0.01" min="0"  class="input-text" name="start_fare[]" id="start_fare" value=""  required oninvalid="setCustomValidity('请输入底价');" oninput="setCustomValidity('')"/>RMB<span></span>
                          </td>
                      </tr>
                      <tr>
                          <td width="10%" align="right">每重量段最小重：</td>
                          <td width="90%">
                              <input type="number" step="0.01" min="0"  class="input-text" name="stage_min_weig[]" id="stage_min_weig" value="" required="" oninvalid="setCustomValidity('请输入每重量段最小重');" oninput="setCustomValidity('')"/>kg<span></span>
                          </td>
                      </tr>
                      <tr>
                          <td width="10%" align="right">每重量段最大重：</td>
                          <td width="90%">
                              <input type="number" step="0.01" min="0"  class="input-text" name="stage_max_weig[]" id="stage_max_weig" value=""  required="" oninvalid="setCustomValidity('请输入每重量段最大重');" oninput="setCustomValidity('')"/>kg<span></span>
                          </td>
                      </tr>
                      <tr>
                          <td width="10%" align="right">续重：</td>
                          <td width="90%">
                              <input type="number" step="0.01" min="0"  class="input-text" name="add_weig" id="add_weig" value=""  required="" oninvalid="setCustomValidity('请输入续重');" oninput="setCustomValidity('')"/>kg<span></span>
                          </td>
                      </tr>
                      <tr>
                          <td width="10%" align="right">续重价：</td>
                          <td width="90%">
                              <input type="number" step="0.01" min="0"  class="input-text" name="add_weig_price" id="add_weig_price" value=""  required="" oninvalid="setCustomValidity('请输入续重价');" oninput="setCustomValidity('')"/>RMB <span></span>
                          </td>
                      </tr>
                  </table>
              </div>
              <div id="wjz" style="display: none; width: 100%" class="table_form">
                  <table cellpadding=0 cellspacing=0 class="table_form" width="100%">
                      <tr>
                          <td width="15%" align="right" style="padding: 0">每重量段最小重：</td>
                          <td width="80">
                              <input type="number" step="0.01" min="0"  class="input-text" name="stage_min_weig[]" class="stage_min_weig" value="" oninvalid="setCustomValidity('请输入每重量段最小重');" oninput="setCustomValidity('')"/>kg<span></span>
                          </td>
                          <td width="100" align="right" style="padding: 0">每重量段最大重：</td>
                          <td width="80">
                              <input type="number" step="0.01" min="0"  class="input-text" name="stage_max_weig[]"class="stage_max_weig" value=""  oninvalid="setCustomValidity('请输入每重量段最大重');" oninput="setCustomValidity('')"/>kg<span></span>
                          </td>
                          <td width="80" align="right">每段单/底价：</td>
                          <td >
                              <input type="number" step="0.01" min="0"  class="input-text" name="start_fare[]" class="start_fare" value=""  oninvalid="setCustomValidity('请输入底价');" oninput="setCustomValidity('')"/>RMB<span></span>
                          </td>
                      </tr>
                  </table>
                  <button id="tjxx"type="button">添加多个信息</button>
              </div>

          <div class="bk15"></div>
          <div class="btn">
              <input type="submit" name="dosubmit" id="dosubmit" value="提交" class='button'>&nbsp;<input type="reset" value="重置" class='button'>
          </div>
      </form>
  </div>
  <script type="text/javascript">
    $("#tjxx").click(function(){
        $("#wjz table").append($("#wjz table tr:first-child").clone());
    })
      //判断是否选中
      $("#wu").change(function(){
          if($("#wu").prop("checked")){
              $("#wjz").css("display","block");
              $("#yjz").css("display","none");
              $("#wjz input").attr("required");
              $("#yjz input").removeAttr("required");
          }
      })
      $("#you").change(function(){
          if($("#you").prop("checked")){
              $("#yjz").css("display","block");
              $("#wjz").css("display","none");
              $("#wjz input").removeAttr("required");
              $("#yjz input").attr("required");
              /*$("#stage_min_weig").val("").parent().parent().css("display","");
              $("#stage_max_weig").val("").parent().parent().css("display","");
              $("#start_weight").parent().parent().css("display","");
              $("#add_weig").val("").parent().parent().css("display","");
              $("#add_weig_price").val("").parent().parent().css("display","");*/
          }
      })
      $("#partition").change(function(){
          if($("#partition").val()==1){
              $("#fuel").removeAttr("required");
              $.getJSON("__MODULE__/zhuanxian/pc",{partition_id:$(this).val()},function(msg){
                  if(msg){
                      $("#country").empty();
                      var chi="";
                      for(var i in msg){
                          chi+= "<option value='"+msg[i].country_id+"'>"+msg[i].ename+"&nbsp;&nbsp;"+msg[i].cname+"</option>"
                      }
                      $(chi).appendTo("#country");
                  }
              })
          }else{
              $("#fuel").attr("required");
              $.getJSON("__MODULE__/zhuanxian/pc",{partition_id:$(this).val()},function(msg){
                  if(msg){
                      $("#country").empty();
                      var chi="";
                      for(var i in msg){
                          chi+= "<option value='"+msg[i].country_id+"'>"+msg[i].ename+"&nbsp;&nbsp;"+msg[i].cname+"</option>"
                      }
                      $(chi).appendTo("#country");
                  }else{
                      alert("分区还没有分配国家");
                  }
              })

          }
      })

      //判断是否已有数据
      $("#channel").change(function(){
          $.getJSON("__MODULE__/zhuanxian/cp", {channel_id: $(this).val()}, function (msg){
              if(msg){
                $("#partition").empty();
                var chi="<option value=''>请选择</option>";
                  for(var i in msg){
                      if(msg[i].partition_id ==1){
                          $("#fuel").removeAttr("required");
                          chi+= "<option value='"+msg[i].partition_id+"' selected>"+msg[i].partition+"</option>";
                      }else{
                          chi+= "<option value='"+msg[i].partition_id+"'>"+msg[i].partition+"</option>";
                      }
                  }
                  $(chi).appendTo("#partition");
              }
          })
              $.getJSON("__MODULE__/zhuanxian/qc",'',function(msg){
                  if(msg){
                      $("#country").empty();
                      var chi="";
                      for(var i in msg){
                          chi+= "<option value='"+msg[i].id+"'>"+msg[i].ename+"&nbsp;&nbsp;"+msg[i].cname+"</option>"
                      }
                      $(chi).appendTo("#country");
                  }
              })
//
          $.getJSON("__MODULE__/zhuanxian/channel_change", {channel_id: $(this).val()}, function (msg){
              if(msg.fuel){
                  $("#fuel").val(msg.fuel);
              }else {
                  $("#fuel").val("");
              }
          })
          if($("#country").val()) {
              $.getJSON("__MODULE__/zhuanxian/add_check_ajax", {
                  country_id: $("#country").val(),
                  channel_id: $(this).val(),partition_id: $("#partition").val()
              }, function (msg) {
                  if(msg.announcements){
                      $("#announcements").val(msg.announcements).attr("readonly","readonly");
                  }else{
                      $("#announcements").val("").removeAttr("readonly");
                  }
                  if(msg.method){
                      $("#method").val(msg.method).attr("readonly","readonly");
                  }else{
                      $("#method").val("").removeAttr("readonly");
                  }
                  if(msg.prescription){
                      $("#Prescription").val(msg.prescription).attr("readonly","readonly");
                  }else{
                      $("#Prescription").val("").removeAttr("readonly");
                  }

              })
          }else{
              $("#announcements").val("").removeAttr("readonly");
              $("#method").val("").removeAttr("readonly");
              $("#Prescription").val("").removeAttr("readonly");
              $("#fuel").val("").removeAttr("readonly");
          }
      })
      $("#country").change(function(){
          if($("#channel").val()) {
              $.getJSON("__MODULE__/zhuanxian/add_check_ajax", {channel_id: $("#channel").val(),country_id: $(this).val(),partition_id: $("#partition").val()
              }, function (msg) {
                  if(msg.announcements){
                      $("#announcements").val(msg.announcements).attr("readonly","readonly");
                  }else{
                      $("#announcements").val("").removeAttr("readonly");
                  }
                  if(msg.method){
                      $("#method").val(msg.method).attr("readonly","readonly");
                  }else{
                      $("#method").val("").removeAttr("readonly");
                  }
                  if(msg.prescription){
                      $("#Prescription").val(msg.prescription).attr("readonly","readonly");
                  }else{
                      $("#Prescription").val("").removeAttr("readonly");
                  }
              })
          }else{
              $("#announcements").val("").removeAttr("readonly");
              $("#method").val("").removeAttr("readonly");
              $("#Prescription").val("").removeAttr("readonly");
          }
      })
  </script>
</body>
</html>





